package com.tingyukeji.fastpay.user.activity;

import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;

import com.tingyukeji.fastpay.R;
import com.tingyukeji.fastpay.base.BaseActivity;
import com.tingyukeji.fastpay.databinding.BusinessRegistrationPhoneActivityBinding;
import com.tingyukeji.fastpay.login.utils.TimerCallBack;
import com.tingyukeji.fastpay.login.utils.UserCountTimer;
import com.tingyukeji.fastpay.utils.FastClickUtils;

/**
 * Created by Administrator on 2016/11/11.
 */

public class BusinessRegistrationPhoneActivity extends BaseActivity implements View.OnClickListener {
    private UserCountTimer countTimer;
    private boolean timerFinish = true;
    private BusinessRegistrationPhoneActivityBinding binding;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Override
    protected void setContentView() {
        super.setContentView();
        binding = DataBindingUtil.setContentView(this, R.layout.business_registration_phone_activity);
    }

    @Override
    protected void initView() {
        super.initView();
        countTimer = new UserCountTimer(60000, 1000, binding.tvGetSmsCode, "秒后重新发送", "获取验证码");
        countTimer.setTimerCallBackListener(new TimerCallBack.TimerCallBackListener() {
            @Override
            public void onFinish() {
                timerFinish = true;
            }
        });
        binding.btNext.setOnClickListener(this);
        binding.tvGetSmsCode.setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.bt_next:
                goActivity(BusinessRegistrationIdCardActivity.class);
                break;
            case R.id.tv_get_sms_code:
                if (timerFinish && !FastClickUtils.isFastClick(500))
                    getSmsCode();
                break;
        }
    }

    private void getSmsCode() {
        timerFinish = false;
        countTimer.start();
    }
}
